<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>一些CSS效果记录</title>
  <style type="text/css">
    :root {
      --button-back-color-a: #3b3efc;
      --button-back-color-b: #5d79ff;
      --button-fore-color: #fff;
      --button-shadow-color: rgba(0, 0, 0, 0.25);
      --button-shadow-focus-color: rgba(0, 0, 0, 0.29);
      --card-back-color: #fff;
      --card-fore-color: #212121;
      --card-border-color: #e4e6ec;
      --card-fore-color-light: #424242;
      --card-shadow-color-a: rgba(240, 242, 247, 0.1);
      --card-shadow-color-b: rgba(0, 32, 128, 0.1);
    }
    * {margin: 0; padding: 0; font-size: 1rem;  font-weight: 400}
    html {
      font-size: 16px;
      scroll-behavior: smooth;
      line-height: 1.5;
    }
    .card {
      padding: 5px 20px;
    }
    .card-title {
      font-size: 1.5rem;
      line-height: 1.375;
      font-weight: 700;
      margin: 0 0 1.25rem;
      color: var(--card-fore-color-light);
      padding-bottom: .5rem;
      border-bottom: 1px solid var(--card-border-color);
    }

    .button {
      color: var(--button-fore-color);
      font-weight: 500;
      transition: all .3s ease;
      padding: .625rem .875rem;
      box-shadow: 0 4px 8px var(--button-shadow-color);
      border: none;
      cursor: pointer;
    }
    .button.button-b {
      background: var(--button-back-color-b);
      min-width: 176px;
      font-size: .875rem;
      border-radius: .5rem;
    }
    .button:focus, .button:hover {
      box-shadow: 0 8px 16px var(--button-shadow-color);
      text-decoration: none;
      outline: none;
    }

    /*2. loading效果*/
    @keyframes bouncing-loader {
      to {
        opacity: .1;
        transform: translate3d(0, -1rem, 0);
      }
    }
    .bouncing-loader {
      display: flex;
      justify-content: center;
    }
    .bouncing-loader > div {
      width: 1rem;
      height: 1rem;
      margin: 3rem 0.2rem;
      background: #8385aa;
      border-radius: 50%;
      animation: bouncing-loader 0.6s infinite alternate;
    }
    .bouncing-loader > div:nth-child(2) {
      animation-delay: 0.2s;
    }
    .bouncing-loader > div:nth-child(3) {
      animation-delay: 0.4s;
    }

    /*3. 上下居中显示*/
    .ghosting {
      height: 300px;
      background: #0ff;
    }
    .ghosting:before {
      content: '';
      display: inline-block;
      height: 100%;
      vertical-align: middle;
    }
    .ghosting p {
      display: inline-block;
      vertical-align: middle;
    }
    /*4. 不规则多边形*/
    .clip-box {
      display: flex;
    }
    .clip-item {
      width: 200px;
      height: 200px;
      background: red;
    }
    .clip-item.triangle {
      clip-path: polygon(0 100%, 100% 100%, 50% 0)
    }
    .clip-item.stairs {
      clip-path: polygon(100% 0, 75% 100%, 25% 100%, 0 0)
    }
    .clip-item.inset {
      /* 
        可以参考： https://www.jianshu.com/p/b1d29c4df147 
        inset使用四个值分别对应“上 右 下 左”的顺序，前4个值对应的是外边距，后4个值对应四个角的圆半径值。
      */
      clip-path:inset(20% 0 20% 0 round 0 0 25% 25%);
    }
    .clip-item.skew {
      height: 48px;
      background: none;
      box-shadow: inset 0 0 20px 5px red;
      transform: skewX(28deg);
      clip-path: polygon(25px 0,100% 0,100% 48px,0 48px);
    }

    /*
      5. 保持宽高比
      参考：http://zihua.li/2013/12/keep-height-relevant-to-width-using-css/
      首先需要知道，一个元素的 padding，如果值是一个百分比，那这个百分比是相对于其父元素的宽度而言的，
        即使对于 padding-bottom 和 padding-top 也是如此。
      另外，在计算 Overflow 时，是将元素的内容区域（即 width / height 对应的区域）和 Padding 区域一起计算的。换句话说，
        即使将元素的 overflow 设置为 hidden，“溢出”到 Padding 区域的内容也会照常显示。
    */
    .tiles {
      display: flex;
    }
    .tile {
      flex: 1;
    }
    .tile .tile-content {
      width: 90%;
      margin: 0 auto;
      height: 0;
      padding-bottom: 50%;
      background: red;
      color: #fff;
    }

    /*
      6. transition动画      
    */
    .tran-box {
      width: 300px;
      padding: 8px;
      border: 1px solid #f60;
      border-radius: 3px;
    }
    .tran-item {
      position: relative;
      display: flex;
      align-items: center;
      overflow: hidden;
    }
    .tran-img {
      width: 112px;
      height: 86px;
      position: relative;
    }
    .tran-item .line {
      position: absolute;
      width: 80%;
      height: 76%;
      left: 10%;
      top: -110%;
      border: 1px solid #fff;
      transform-origin: left;
      transition: all 0.5s;
    }
    .tran-item .tran-img-tit {
      position: absolute;
      font-size: 14px;
      font-weight: 600;
      color: red;
      width: 100%;      
      text-align: center;
      left: 0;
      top: 100%;     
      opacity: 0;
      transition: all 0.5s 0.4s;
    }       
    .tran-img img {
      width: 100%;
      height: 100%;
      display: block;
    }
    .tran-item:hover .line {
      top: 14%;
      opacity: 1;
      /* transform: rotate(45deg); */
    }
    .tran-item:hover .tran-img-tit {
      top: 44%;
      opacity: 1;
    }
    .tran-txt { flex: 1; padding-left: 6px;}
    .tran-txt h2 { font-size: 14px; color: #f60;}
    .tran-txt p { font-size: 12px; line-height: 20px;}

    /*
      7. --------loading bar---------
    */
    .spinner {
        margin: auto;
        width: 60px;
        height: 60px;
        position: absolute ;
        left: 0;
        top: 0;
        right: 0;
        bottom: 0
    }

    .container1 > div, .container2 > div, .container3 > div {
        width: 16px;
        height: 16px;
        /*background-color: #67cf22;*/
        background-color: #3498db;
        border-radius: 100%;
        position: absolute;
        -webkit-animation: bouncedelay 1.2s infinite ease-in-out;
        animation: bouncedelay 1.2s infinite ease-in-out;
        -webkit-animation-fill-mode: both;
        animation-fill-mode: both;
    }

    .spinner .spinner-container {
        position: absolute;
        width: 100%;
        height: 100%;
    }

    .container2 {
        -webkit-transform: rotateZ(45deg);
        transform: rotateZ(45deg);
    }

    .container3 {
        -webkit-transform: rotateZ(90deg);
        transform: rotateZ(90deg);
    }

    .circle1 { top: 0; left: 0; }
    .circle2 { top: 0; right: 0; }
    .circle3 { right: 0; bottom: 0; }
    .circle4 { left: 0; bottom: 0; }

    .container2 .circle1 {
        -webkit-animation-delay: -1.1s;
        animation-delay: -1.1s;
    }

    .container3 .circle1 {
        -webkit-animation-delay: -1.0s;
        animation-delay: -1.0s;
    }

    .container1 .circle2 {
        -webkit-animation-delay: -0.9s;
        animation-delay: -0.9s;
    }

    .container2 .circle2 {
        -webkit-animation-delay: -0.8s;
        animation-delay: -0.8s;
    }

    .container3 .circle2 {
        -webkit-animation-delay: -0.7s;
        animation-delay: -0.7s;
    }

    .container1 .circle3 {
        -webkit-animation-delay: -0.6s;
        animation-delay: -0.6s;
    }

    .container2 .circle3 {
        -webkit-animation-delay: -0.5s;
        animation-delay: -0.5s;
    }

    .container3 .circle3 {
        -webkit-animation-delay: -0.4s;
        animation-delay: -0.4s;
    }

    .container1 .circle4 {
        -webkit-animation-delay: -0.3s;
        animation-delay: -0.3s;
    }

    .container2 .circle4 {
        -webkit-animation-delay: -0.2s;
        animation-delay: -0.2s;
    }

    .container3 .circle4 {
        -webkit-animation-delay: -0.1s;
        animation-delay: -0.1s;
    }
    /* -----------------卷帘分割条 end------------------- */
    @keyframes bouncedelay {
      0%, 80%, 100% {
        transform: scale(0.0);
      } 
      40% {
        transform: scale(1.0);
      }
    }
    /*--------loading bar end---------*/
  </style>
</head>
<body>
  <div class="card">
    <h4 class="card-title">1. 按钮效果</h4>
    <div class="card-content">
        <button class="button button-b button-codepen">按钮效果</button>
    </div>
  </div>
  <div class="card">
    <h4 class="card-title">2. loading效果</h4>
    <div class="card-content">
        <div class="bouncing-loader">
          <div></div>
          <div></div>
          <div></div>
        </div>
    </div>
  </div>
  <div class="card"> <!-- 上下居中显示 -->
    <h4 class="card-title">3. 上下居中显示</h4>
    <div class="card-content">
        <div class="ghosting"><p>Vertically centered without changing the position property.<br />上下居中显示上下居中显示 </p></div>
    </div>
  </div>
  <div class="card"> <!-- 不规则多边形 -->
    <h4 class="card-title">4. 不规则多边形</h4>
    <div class="card-content">
      <div class="clip-box">
        <div class="clip-item triangle"> <!--三角形-->
        </div>
        <div class="clip-item stairs"> <!--梯形-->
        </div>
        <div class="clip-item inset"> <!--圆角-->
        </div>
        <div class="clip-item skew"> <!--多边形斜切-->
        </div>
      </div>
    </div>
  </div>
  <div class="card"> <!-- 保持宽高比 -->
    <h4 class="card-title">5. 保持宽高比</h4>
    <div class="card-content">
      <div class="tiles">
        <div class="tile">
          <div class="tile-content">内容区域保持宽高比</div>
          <h2 class="tile_title">30 Seconds of CSS</h2>
        </div>
        <div class="tile">
          <div class="tile-content">内容区域保持宽高比</div>
          <h2 class="tile_title">30 Seconds of CSS</h2>
        </div>
        <div class="tile">
          <div class="tile-content">内容区域保持宽高比</div>
          <h2 class="tile_title">30 Seconds of CSS</h2>
        </div>
      </div>
    </div>
  </div>
  <div class="card"> <!-- 一个小小transition动画效果 -->
    <h4 class="card-title">6. 一个小小transition动画效果</h4>
    <div class="card-content">
      <div class="tran-box">
        <div class="tran-item">          
          <div class="tran-img">
            <img src="images/animal.jpg" />
            <div class="line"></div>
            <div class="tran-img-tit">深圳动物园</div>
          </div>
          <div class="tran-txt">
            <h2>深圳动物园</h2>
            <p>深圳动物园是全国第一家由企业投资兴办的市政项目。建于山清水秀的深圳西丽湖畔，占地面积64万平方米，总投资2.5亿人民币。</p>
          </div>
        </div>        
      </div>
    </div>
  </div>
  <div class="card"> <!-- CSS动画做转动loading效果 -->
    <h4 class="card-title">7. CSS动画做转动loading效果</h4>
    <div class="card-content" style="position: relative; height: 200px; background:#000;">
      <div id='loadingbar' class="spinner">
        <div class="spinner-container container1">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
        <div class="spinner-container container2">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
        <div class="spinner-container container3">
          <div class="circle1"></div>
          <div class="circle2"></div>
          <div class="circle3"></div>
          <div class="circle4"></div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>